#include <cstdio>
int main()
{
    int x, y;
    int x1, y1;
    scanf("%d %d", &x, &y);
    x1 = x;
    y1 = y;
    int N;
    scanf("%d", &N);
    int i, j;
    int m1 = 0, m2 = 0, n1 = 0, n2 = 0, sum = 0;
    for (i = 0; i < N; i++)
    {
        if (x == -1 || y == -1)
            break;
        scanf("%d %d %d %d", &m1, &m2, &n1, &n2);
        sum = m1 + n1;
        if (m2 == sum && n2 == sum)
            continue;
        if (m2 == sum)
            x--;
        if (x == -1)
            break;
        if (n2 == sum)
            y--;
        if (y == -1)
            break;
    }
    if (x == -1)
    {
        printf("A\n");
        printf("%d", y1 - y);
        return 0;
    }
    if (y == -1)
    {
        printf("B\n");
        printf("%d", x1 - x);
        return 0;
    }
    return 0;
}
